<?php
// +----------------------------------------------------------------------
// | 萤火商城系统 [ 致力于通过产品和服务，帮助商家高效化开拓市场 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2024 https://www.yiovo.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 这不是一个自由软件，不允许对程序代码以任何形式任何目的的再发行
// +----------------------------------------------------------------------
// | Author: 萤火科技 <admin@yiovo.com>
// +----------------------------------------------------------------------
declare (strict_types = 1);

namespace app\store\model\jia;

use app\common\model\jia\Dengji as DengjiModel;
use app\store\model\jia\Floor as FloorModel;
use think\facade\Db;
/**
 * 文章分类模型
 * Class Category
 * @package app\store\model\article
 */
class Dengji extends DengjiModel {


	public function getList(array $param = []) {
		// 查询参数
		$params = $this->setQueryDefaultValue($param, [
			'searchValue' => '', // 文章标题
			'manageId' => 0, // 文章分类id
			'status' => -1, // 文章状态
			'betweenTime' => [], // 起止时间
		]);
		// 检索查询条件
		$filter = [];
			// 起止时间
		if (!empty($params['betweenTime'])) {
			$times = between_time($params['betweenTime']);
			$filter[] = ['order.create_time', '>=', $times['start_time']];
			$filter[] = ['order.create_time', '<', $times['end_time'] + 86400];
		}

		// 文章标题
		!empty($params['searchValue']) && $filter[] = ['order.real_name|order.mobile', 'like', "%{$params['searchValue']}%"];


		// 文章状态
		$params['status'] > -1 && $filter[] = ['status', '=', $params['status']];
		// 查询列表数据
		$data = $this->alias('d')->with(['order'=>['build','goods','extractClerk']])
		->join('order','order.order_id=d.order_id')
			->where($filter)
			->where('order.is_delete', '=', 0)
			->order(['order.create_time' => 'desc'])
			->select()->toArray();

		// 获取文章的图片和分类
		return $data;
	}

	
}
